<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var obj = {
            id: 1,
            name: "xuying",
            age: 18
        };
        //以前定义修改属性的方法
        // obj.intrest = 'sing';
        // obj.name = '666';
        // console.log(obj);
        //新增
        Object.defineProperty(obj, 'task', { //新增 默认不让遍历
            value: 'housework'
        });
        Object.defineProperty(obj, 'name', { //修改属性值
            value: 'nb'
        });

        Object.defineProperty(obj, 'id', { //限定属性
            writable: false, //不能重写 
            enumerable: false, //不让遍历
            configurable: false //不允许删除  不能修改第三个参数的特性
        })
        obj.id = 9;
        console.log(obj);
        console.log(Object.keys(obj));
        delete obj.id;
        console.log(obj);
    </script>
</body>

</html>